{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 哈希表伪码逻辑\n",
    "class MyHashMap:\n",
    "\n",
    "    def __init__(self):\n",
    "        self.table = [None] * 1000\n",
    "\n",
    "    # 增/改，复杂度 O(1)\n",
    "    def put(self, key, value):\n",
    "        index = self.hash(key)\n",
    "        self.table[index] = value\n",
    "\n",
    "    # 查，复杂度 O(1)\n",
    "    def get(self, key):\n",
    "        index = self.hash(key)\n",
    "        return self.table[index]\n",
    "\n",
    "    # 删，复杂度 O(1)\n",
    "    def remove(self, key):\n",
    "        index = self.hash(key)\n",
    "        self.table[index] = None\n",
    "\n",
    "    # 哈希函数，把 key 转化成 table 中的合法索引\n",
    "    # 时间复杂度必须是 O(1)，才能保证上述方法的复杂度都是 O(1)\n",
    "    def hash(self, key):\n",
    "        # ...\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(0 % 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print( 5 % 5 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "science39",
   "language": "python",
   "name": "science39"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
